/*
 * send_11mbps.c
 * Created on December 27, 2005; 1:56 PM
 * by vramadurai
 */

/************ System Header Files ***************/
#include <stdio.h>
#include <stdlib.h>

/************ Private Header Files **************/
#include "HsTypes.h"
#include "PhyDebug.h"
#include "PhyStruct.h"
#include "PmdGlobals.h"
#include "PhyConstants.h"
#include "tables.h"
#include "tx_functions.h"
#include "iqdma_3500.h"
#include "icrdefs_3500.h"
#include "thread_globals.h"

void
send_11mbps(
                struct HS_PhyTx11bStr  *HS_PhyTx11bPtrTh1,
                ePHYSTATES_TH	*ePhyState,
                hs_uint8_t		*ucStateTable4Bit,
                hs_uint32_t *crctab
            )
{
	hs_uint32_t crc;
    hs_uint8_t ucBit;
    hs_int32_t 	payload_bytes;
    hs_uint16_t usLength;
    hs_uint8_t	*psPayloadByte;
    hs_uint8_t *crc_shared;
    hs_int32_t i;

	crc_shared = HS_PhyTx11bPtrTh1->crc_shared;
    usLength = HS_PhyTx11bPtrTh1->usLength;
    psPayloadByte = (hs_uint8_t*)HS_PhyTx11bPtrTh1->psPayloadByte;

	crc = 0xFFFFFFFFU;

	tx_thread1to2_flag1 = 1;

	for(payload_bytes=0; payload_bytes<usLength-4; payload_bytes++){

        ucBit = psPayloadByte[payload_bytes];

		// CRC
		crc ^= ucBit;
		crc = crctab[crc & 0xf] ^ (crc >> 4);
		crc = crctab[crc & 0xf] ^ (crc >> 4);
    }

    crc = crc ^ 0xffffffffU;

    for(i=0; i<4; i++){
    	crc_shared[i] = ((crc >> (8*i)) & 0xFF);
    }

    *ePhyState  = PHY_STATE_SWITCH_OFF_TH;
}





